home *** CD-ROM | disk | FTP | other *** search
- /**
- --
- -- App: Getting Started w/QD GX (WWDC)
- --
- --
- -- Version: 1.0 4/93: added all of the calls required to support the "Getting
- -- Started with QuickDraw™ GX" session at the WWDC '93
- --
- -- 8/93: updated file to work with the ß2 "GXified" interface files
- --
- --
- -- File: Getting Started GX - printing.c
- --
- --
- -- Comments: This code contains all of the functions required to print the QuickDraw GX shapes we created.
- -- We use the QuickDraw GX printing method which takes a picture and passes it to the QuickDraw GX
- -- printing system. The picture will always contains what is in the front window.
- --
- -- If QuickDraw GX printing systems has not been installed, the printing menu items in the File
- -- menu will be dis-abled.
- --
- --
- -- Components: Getting Started GX - main.c
- -- Getting Started GX - main.h
- -- Getting Started GX - shapes.c
- -- Getting Started GX - printing.c
- -- Getting Started GX - misc.c
- -- Getting Started QD GX.π.rsrc
- --
- -- The file titled: "Getting Started GX - main.c" contains the code required to
- -- intialize and tear down the QuickDraw GX world, and the event loop.
- --
- -- The file titled: "Getting Started GX - shapes.c" contains of the code used to
- -- create and manipulate the shapes draw into the window.
- --
- --
- -- QuickDraw GX
- -- Libraries
- -- Used: This application uses the following QuickDraw GX library code files:
- -- "color library.c", "font library.c", "graphics debug library.c",
- -- "layout library.c", "qd library.c", "shape library.c",
- -- "transferMode library.c", and "transform library.c".
- --
- --
- -- Notes: 1) Print this file in landscape for the best results
- -- 2) If you are using THINK C v5.x, I have added THINK markers to navigate the code.
- -- 3) This code was adapted from the "Banana Jr." QuickDraw GX sample.
- --
- --
- -- Author: Pete "Luke" Alexander
- -- Developer Technical Support
- -- AppleLink: DEVSUPPORT
- --
- --
- -- ©1992 - 1993 Apple Computer, Inc.
- -- All rights reserved.
- --
- **/
-
- #include "PrintingManager.h"
- #include "Getting Started GX - main.h"
-
-
- /*------ SetUpEditMenuRec ------------------------------------------------------------------------------------*/
- //
- // This routine sets up an gxEditMenuRecord which references our edit menu. This structure
- // is used by the GXJobDefaultFormatDialog and GXJobPrintDialog calls to allow cut, copy, & paste
- // operations from the dialogs.
- //
- void SetUpEditMenuRec(gxEditMenuRecord *edMenuRec)
- {
-
- edMenuRec->editMenuID = mEdit;
- edMenuRec->cutItem = iCut;
- edMenuRec->copyItem = iCopy;
- edMenuRec->pasteItem = iPaste;
- edMenuRec->clearItem = iClear;
- edMenuRec->undoItem = iUndo;
- }
-
-
- /*------ DoFormat ------------------------------------------------------------------------------------*/
- //
- // This routine performs GX's equivalent of the Page Setup (PrStlDialog) call of
- // the old printing architecture.
- //
- OSErr DoFormat(WindowPtr theWindow, gxDialogResult *result)
- {
- OSErr err;
- gxEditMenuRecord edMenuRec;
- gxJob documentJob;
-
- //
- // If we have a non-nil WindowPtr, set up our edit menu record and handle the job
- // format dialog. Remember to check for errors.
- //
- if (theWindow)
- {
- documentJob = GetDocJob(theWindow);
- SetUpEditMenuRec(&edMenuRec);
- *result = GXJobDefaultFormatDialog(documentJob, &edMenuRec);
- }
-
- return GXGetJobError(documentJob);
- }
-
-
- /*------ DoPrinting ----------------------------------------------------------------------------------*/
- //
- // This routine performs QuickDraw GX's equivalent of the Print gxJob Dialog (PrJobDialog) call of
- // the old printing architecture, and then prints the document if the user wants to.
- //
- OSErr DoPrinting(WindowPtr theWindow)
- {
- OSErr err = noErr;
- gxDialogResult result;
- gxEditMenuRecord edMenuRec;
- gxJob docJob;
-
-
- //
- // If we have a non-nil WindowPtr, set up our edit menu record and handle the print
- // job dialog. Remember to check for errors. If no errors occur, and the user clicks
- // ok, print the window's document.
- //
- if (theWindow)
- {
- docJob = GetDocJob(theWindow);
-
- SetUpEditMenuRec(&edMenuRec);
- result = GXJobPrintDialog(docJob, &edMenuRec);
- err = GXGetJobError(docJob);
-
- if ((result == gxOKSelected) && !(err))
- err = DoPrintOne(theWindow);
- }
-
- return err;
- }
-
-
-
- /*------ DoPrintOne ----------------------------------------------------------------------------------*/
- //
- // This routine prints one copy of the window's document using whatever job and format
- // is currently attached to it. (If the window wwere just created and then the user
- // selected Print One w/o first selecting Page Setup…, the system default job and
- // format are stored with this document.
- //
- OSErr DoPrintOne(WindowPtr theWindow)
- {
- OSErr err = noErr;
- gxJob documentJob;
- Str255 windowTitle;
-
- //
- // If we have a non-nil WindowPtr, start the print job, print a page and then finish
- // the job. Since we have just a one page document, we don't bother counting pages.
- // Remember to check those errors!
- //
- if (theWindow)
- {
- documentJob = GetDocJob(theWindow);
- GetWTitle(theWindow, windowTitle);
-
- GXStartJob(documentJob, windowTitle, 1);
- err = GXGetJobError(documentJob);
-
- if (!err)
- {
- GXPrintPage(documentJob, 1,GXGetJobFormat(documentJob, 1), GetDocShape(theWindow));
- err = GXGetJobError(documentJob);
- }
-
- GXFinishJob(documentJob);
- if (!err) err = GXGetJobError(documentJob);
- }
- return err;
- }
-
-
-
-